/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beatbox;
import java.util.Observer;
import java.util.Observable;
/**
 *Class for getting the examples from chuck
 *
 *can bind to examplesLeft then do onChange
 * @author Kyle
 */

public class FeatureListenerAdapter extends Observer{
    public-read var examplesLeft: Number;

    public-init var javaFeatureListener: FeatureListener
        on replace { javaFeatureListener.addObserver(this); }

    override public function update (arg0 : Observable, arg1 : Object) : Void {
        FX.deferAction(
            function(): Void {
                examplesLeft = javaFeatureListener.examplesLeft();
                println("example received!");
            }
        )
    }
    //Actually start storing examples
    public function startListening() {
        javaFeatureListener.startListening();
    }

    //stop storing examples
    public function stopListening() {
        javaFeatureListener.stopListening();
    }

    public function getNextExample():Example {
        javaFeatureListener.getNextExample();
    }
}
